﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using MySql.Data.MySqlClient;

namespace Fee.Mapping
{
    public class OrderContractMapping : IEntityTypeConfiguration<OrderContract>
    {
        public void Configure(EntityTypeBuilder<OrderContract> builder)
        {
            builder.HasKey(_ => _.Id);
            builder.Property(_ => _.Id).ValueGeneratedOnAdd();
            builder.Property(_ => _.Amount);
            builder.Property(_ => _.ContractNo).HasMaxLength(24);

            builder.Property(_ => _.SignTime);

            builder.Property(_ => _.FinishTime);

            builder.HasOne(_ => _.FrameworkContract);

            builder.Property(_ => _.OrderNo).HasMaxLength(48);
            builder.Property(_ => _.Status);

            builder.HasOne(_ => _.Project);
            builder.Property(f => f.Name).HasMaxLength(256);
            builder.Property(f => f.AmountWithoutTax);
            builder.Property(f => f.Contact).HasMaxLength(128);
            builder.Property(f => f.Comment).HasMaxLength(256);
            builder.HasOne(f => f.Vendor);

            builder.Property(_ => _.Tax);
            builder.Property(_ => _.ProjectNo).HasMaxLength(32);


            builder.ToTable("fee_OrderContract");
        }
    }
}